import multiprocessing  # 导入进程工具包
import time

def coding():
    for i in range(21):
        time.sleep(0.1)
        print(f"正在进行第{i}个进程")

def apple():
    for i in range(16):
        time.sleep(0.2)
        print(f"正在吃第{i}个苹果")


if __name__ == '__main__':   # 注意要使用main进程去加载
    p1 = multiprocessing.Process(target = coding)# 通过进程类  实例化进程 对象  语句为: 子对象进程 = multiprocessing.Process()
    p2 = multiprocessing.Process(target = apple)
    p1.start()
    p2.start()  # 启动进程执行任务语句为: 进程对象.start()

